ActiveReports 9 > ActiveReports User Guide > Samples and Walkthroughs > Samples > Section Report > Layout > Inheritance |
This sample explains the method to inherit a report at runtime and design time. The Inheritance sample solution comprises of two classes - the parent class and the child class for both inheritance at runtime and design time.
Sample Location
Visual Basic.NET
<User Folder>\GrapeCity Samples\ActiveReports 9\Section Reports\Layout\Inheritance\VB.NET
C#
<User Folder>\GrapeCity Samples\ActiveReports 9\Section Reports\Layout\Inheritance\C#
Runtime Features
When you run the sample, the report is created and displayed, providing you with the choice of two options - Inheritance Report created at RunTime and Inheritance Report created at Design Time. By clicking a button on the form, you get a report that inherits another class at runtime or at design time.
Inheritance Report created at RunTime
The rptInheritBase class is the inheritance class for the generated report when the Inheritance Report created at RunTime button is clicked on the form. The rptInheritBase class inherits the SectionReport class of the GrapeCity.ActiveReports namespace as parent class. It is possible to use DataInitialize event or FetchData event in this class and also possible to load csv file and set values for csv files. It defines the CsvPath property which gets csv file path.
The rptInheritChild class inherits the rptInheritBase class and is a class which only defines the report design. By adding the event handler for inheritance in the constructor and setting for csv file in CsvPath property, it is possible to perform rendering of data executed by event of BaseReport which is the inheritance class.
Inheritance Report created at Design Time
The rptDesignBase class is the inheritance class for the generated report when the Inheritance Report created at Design Time button is clicked on the form. The rptDesignBase class inherits SectionReport class of the GrapeCity.ActiveReports namespace as parent class. Using this class, you can place any control (ReportInfo controls etc. to display report title, page number, page count) you wish to inherit in PageHeader section and PageFooter section. The rptDesignChild class is inherited from rptDesignBase class. It only defines the design of Detail section. PageHeader section and PageFooter section use the design of rptDesignBase class which is an inherited class. DataSource setting can be performed from rptDesignChild class.
Caution: If you have not run the project even once, an error occurs when you try to open the report designers of the inherited classes rptInheritChild or rptDesignChild from the solution explorer. In case this error occurs, Build the project once before opening the report. |
Project Details
ViewerForm
rptDesignBase
rptDesignChild
rptInheritBase
rptInheritChild